package com.ailink.basic.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class FutureTaskTst {
    public static class MyCall implements Callable<String> {
        @Override
        public String call() throws Exception {
            System.out.println("work");
            Thread.sleep(5 * 1000);
            System.out.println("done");
            return "my call";
        }
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(new MyCall());
        new Thread(futureTask).start();
        System.out.println("start");
        System.out.println(futureTask.get());
    }
}
